package 设计模式.decorator;

/**
 * @功能
 * 装饰模式
 * @创建时间 2020/5/3
 */
public interface ICar {
    void move();
}
class  Car implements ICar{

    @Override
    public void move() {
        System.out.println("陆地上跑");
    }
}
class SuperCar implements ICar{
    public SuperCar(ICar car) {
        this.car = car;
    }

    private ICar car;

    @Override
    public void move() {
      car.move();
    }
}
class FlyCar extends SuperCar{

    public FlyCar(ICar car) {
        super(car);
    }
    public void fly(){
        System.out.println("天上飞");
    }
    @Override
    public void move() {
        super.move();
        fly();
    }
}
class WaterCar extends SuperCar{

    public WaterCar(ICar car) {
        super(car);
    }
    public void swim(){
        System.out.println("水里游");
    }
    @Override
    public void move() {
        super.move();
        swim();
    }
}
class AiCar extends SuperCar{

    public AiCar(ICar car) {
        super(car);
    }
    public void auto(){
        System.out.println("自己走");
    }
    @Override
    public void move() {
        super.move();
        auto();
    }
}
